﻿(function ($) {

    $.fn.isNumber = function () {
        var value = $(this).val();
        var expression = /^[0-9]{1,10}$/i
        var testresults;
        if (value == '') {
            return false;
        } else {
            if (expression.test(value))
                testresults = true;
            else {
                testresults = false;
            }
            return testresults;
        }
    }

    //$.fn.isDate = function (format) {
    //var validateDate.months = {
    //    jan: 0, feb: 1, mar: 2, apr: 3, may: 4, jun: 5,
    //    jul: 6, aug: 7, sep: 8, oct: 9, nov: 10, dec: 11
    //};

    //    var string = $(this).val();
    //    if (format == "dd-MMM-yyyy") {        
    //        var m = /^([0-9]?\d)-(\w{3})-(\d{4})$/.exec(string);
    //        if (!m) return false;
    //        var month = validateDate.months[m[2].toLowerCase()];
    //        if (typeof month != "number") return false;
    //        var date = +m[1];
    //        var year = +m[3];
    //        var d = new Date(year, month, date);

    //        return (d.getDate() == date && d.getMonth() == month && (year == d.getFullYear()));
    //    }
    //    else if (format == "MMM, dd yyyy") {
    //        var m = /^(\w{3}),([0-9]?\d) (\d{4})$/.exec(string);
    //        if (!m) return false;
    //        var month = validateDate.months[m[1].toLowerCase()];
    //        if (typeof month != "number") return false;
    //        var date = +m[2];
    //        var year = +m[3];
    //        var d = new Date(year, month, date);        
    //        return (d.getDate() == date && d.getMonth() == month && (year == d.getFullYear()));
    //    }
    //}



    $.fn.isEmail = function () {
        var EmailId = $(this).val();
        var expression = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
        var testresults;
        if (EmailId == '') {
            document.getElementById(ControlId).focus();
            return false;
        } else {
            if (expression.test(EmailId))
                testresults = true
            else {
                document.getElementById(ControlId).focus();
                testresults = false
            }
            return testresults;
        }
    }

} (jQuery));